import { defineStore } from 'pinia'

interface Languages {
  en: string
  zh: string
  tw: string
  hk: string
  [key: string]: string
}
const useLanguageStore = defineStore('language', () => {
  const language = ref<string>('en')
  function updateLanguage(lang: string) {
    language.value = lang
  }
  return {
    language,
    updateLanguage,
    'Accept-Language': computed(() => {
      const languageMap: Languages = {
        en: 'en-US',
        zh: 'zh-CN',
        tw: 'zh-HK',
        hk: 'zh-HK',
      }
      return languageMap[language.value]
    }),
  }
})

export default useLanguageStore
